package artexercise;

/**
 * 测试运行器 - 完全兼容版本
 */
public class TestRunner {

    // 辅助方法：创建重复字符串（替代String.repeat）
    private static String createRepeatString(String str, int count) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < count; i++) {
            sb.append(str);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println("开始执行单元测试...\n");

        // 创建测试实例
        ArithmeticExpressionTest test = new ArithmeticExpressionTest();
        boolean allTestsPassed = true;

        try {
            test.testAdditionExpression();
        } catch (AssertionError e) {
            System.out.println("❌ 加法测试失败: " + e.getMessage());
            allTestsPassed = false;
        }

        try {
            test.testSubtractionExpression();
        } catch (AssertionError e) {
            System.out.println("❌ 减法测试失败: " + e.getMessage());
            allTestsPassed = false;
        }

        try {
            test.testExerciseGeneration();
        } catch (AssertionError e) {
            System.out.println("❌ 习题生成测试失败: " + e.getMessage());
            allTestsPassed = false;
        }

        try {
            test.testMixedExerciseGeneration();
        } catch (AssertionError e) {
            System.out.println("❌ 混合习题测试失败: " + e.getMessage());
            allTestsPassed = false;
        }

        try {
            test.testFullExerciseSet();
        } catch (AssertionError e) {
            System.out.println("❌ 完整习题集测试失败: " + e.getMessage());
            allTestsPassed = false;
        }

        System.out.println("\n" + createRepeatString("=", 50));
        if (allTestsPassed) {
            System.out.println("🎉 所有单元测试通过！");
        } else {
            System.out.println("❌ 部分测试失败，请检查代码！");
        }
        System.out.println(createRepeatString("=", 50));
    }
}